<template>
    <div>
        <h1>{{msg}}</h1>
        <el-link type="info" href="/">返回页面1</el-link>
        <br/>
    <el-button type="primary" v-on:click="gotoIndex">回到首页</el-button>
    <p>Count:{{itemCount}}</p>
    <el-table
        :data="items"
        style="width:100%">
        <el-table-column
            prop="id"
            label="Id"
            width="180">
        </el-table-column>
        <el-table-column
            prop="name"
            label="Name">
        </el-table-column>
    </el-table>
    </div>
</template>

<script>
import { mapState,mapGetters } from 'vuex'
export default {
    name:'DemoTheOne',
    data(){
        return{
            msg:'页面2'
        }
    },
    computed:{
        ...mapState({
            items : state => state.oneDemo.items
        }),
        ...mapGetters('oneDemo',{
            itemCount:'itemCount'
        })
    },
    created () {
        this.$store.dispatch('oneDemo/queryItems',{});
    },
    methods:{
        toBack(){
            this.$router.go(-1)
        },
        gotoIndex(){
            this.$router.push('/')
        }
    }
}
</script>




<style lang="sass" scoped>

</style>
